package com.solo.system.model.user;

import com.solo.system.api.entity.SysUserPost;
import com.solo.system.model.user.req.AssignPostReq;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 用户角色转换类
 * @author 十一
 * @since 2024/10/17
 * 人生若只如初见，何事秋风悲画扇
 **/
@Mapper
public interface SysUserPostConvert {

    SysUserPostConvert INSTANCE = Mappers.getMapper(SysUserPostConvert.class);
    
    default List<SysUserPost> convert(AssignPostReq bean) {
        return bean.getPostIds().stream().map(postId -> {
            SysUserPost entity = new SysUserPost();
            entity.setUserId(bean.getUserId());
            entity.setPostId(postId);
            return entity;
        }).toList();
    }

}
